package com.guigu.liuzhireng.controller;

import com.guigu.aop.OpLog;
import com.guigu.liuzhireng.pojo.PageVo;
import com.guigu.liuzhireng.pojo.Role;
import com.guigu.liuzhireng.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("Role.do")
public class RoleController {

    @Autowired
    RoleService roleService;

    @RequestMapping("list")
    @ResponseBody
    public List<Role> list(){
        return roleService.list();
    }

    @RequestMapping("Page")
    @ResponseBody
    public PageVo<Role> Page(@RequestBody PageVo<Role> pageVo){
        return roleService.Page(pageVo.getObj(),pageVo.getNum(),pageVo.getSize());
    }

    @RequestMapping("Add")
    @OpLog(opModule = "角色模块",operType = "添加角色",operDesc = "此方法用于添加角色")
    public String Add(Role role){
        int i = roleService.insert(role);
        return "/role/Role.html";
    }

    @RequestMapping("UpDate")
    @OpLog(opModule = "角色模块",operType = "修改角色",operDesc = "此方法用于修改角色")
    public String UpDate(Role role){
        int i = roleService.update(role);
        return "/role/Role.html";
    }

    @RequestMapping("Delete")
    @OpLog(opModule = "角色模块",operType = "删除角色",operDesc = "此方法用于删除角色")
    public String Delete(Integer id){
        int i = roleService.delete(id);
        return "/role/Role.html";
    }

}
